import Vue from 'vue'
import Router from 'vue-router'
/* Layout */
import Layout from '../views/layout/Layout'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in subMenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if false, the item will hidden in breadcrumb(default is true)
  }
 **/
export const constantRouterMap = [
  {path: '/login', component: () => import('@/views/auth/Login'), hidden: true},
  {path: '/register', component: () => import('@/views/auth/Register'), hidden: true},//注册页面
  {path: '/404', component: () => import('@/views/404'), hidden: true},
  // {path: '/reset_password', component: () => import('@/views/login/resetPassword'), hidden: true},
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: '首页',
    hidden: false,
    children: [{
      path: 'dashboard',
      meta: {title: '大盘', icon: 'dashboard'},
      component: () => import('@/views/dashboard/index')
    }]
  },
  {
    path: '/gateway',
    component: () => import('@/views/layout/Layout'),
    redirect: '/gateway/actions',
    name: 'Gateway',
    roles: [],
    meta: {title: '网关配置', icon: 'gateway'},
    children: [
      {
        path: 'actions',
        name: 'Actions',
        component: () => import('@/views/system_actions/ActionMapping'),
        meta: {title: '接口配置'}
      },
      {
        path: 'routes',
        name: 'Routes',
        component: () => import('@/views/zuul_routes/Routes'),
        meta: {title: '路由配置'}
      },

      {
        path: 'actions/detail',
        name: 'ActionDetail',
        hidden: true,
        component: () => import('@/views/system_actions/ActionDetail'),
        meta: {title: '接口详细信息'}
      }
    ]
  },
  {
    path: '/authorization',
    component: () => import('@/views/layout/Layout'),
    redirect: '/authorization/roles',
    name: 'Authorization',
    roles: [],
    meta: {title: '权限控制', icon: 'auth'},
    children: [
      {
        path: 'roles',
        name: 'Roles',
        component: () => import('@/views/system_roles/Roles'),
        meta: {title: '角色管理'}
      },
      {
        path: 'grant',
        name: 'GrantForRole',
        component: () => import('@/views/system_roles/RoleGrant'),
        meta: {title: '权限管理'}
      }
    ]
  },
  {
    path: '/users',
    component: () => import('@/views/layout/Layout'),
    redirect: '/users',
    name: 'Users',
    roles: [],
    meta: {title: '用户中心', icon: 'user'},
    children: [
      {
        path: '',
        name: 'List',
        component: () => import('@/views/system_users/UserList'),
        meta: {title: '用户列表'}
      },
      {
        path: 'data',
        name: 'UserData',
        component: () => import('@/views/system_users/UserList'),
        meta: {title: '用户分析'}
      }
    ]
  },
  {
    path: '/log',
    component: () => import('@/views/layout/Layout'),
    redirect: '/log/login',
    name: 'Log',
    meta: {
      title: '系统监控',
      icon: 'security',
      // roles: ['ROLE_SENIOR']
    },
    children: [
      {
        path: 'login',
        meta: {title: '登录日志'},
        name: 'Login',
        component: () => import('@/views/dashboard/index'), // Parent router-view
      },
      {
        path: 'operate',
        meta: {
          title: '操作记录',
          // roles: ['ROLE_SENIOR']
        },
        name: 'Operate',
        component: () => import('@/views/test/EditorTest'), // Parent router-view
      }
    ]
  },
  {path: '*', redirect: '/404', hidden: true}
]

export default new Router({
  mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  // 异步路由

]
